#include <iostream>
using namespace std;
 
const int N = 100007;
int f[N];
 
int main()
{
    f[1] = 1, f[2] = 2;
    int flag = -1;  // 记录第一个大于六位数的i
    for(int i = 3; i < N; ++i)
    {
        f[i] = f[i - 1] + f[i - 2];
        if(f[i] >= 999999)
        {
            f[i] %= 1000000;
            if(flag == -1)
                flag = i;
        }
    }
    
    int n = 0;
    while(cin >> n)
    {
        if(n >= flag)
            printf("%06d\n", f[n]);
        else
            cout << f[n] << endl;
    }
    return 0;
}